<script>
import { defineComponent } from "vue";

import * as echarts from "echarts";

export default defineComponent({
    data() {},
    methods: {
        init() {
            // 绘制图表
            this.myChart.setOption({
                legend: {
                    top: 'bottom'
                },
                toolbox: {
                    show: true,
                    feature: {
                        mark: { show: true },
                        dataView: { show: true, readOnly: false },
                        restore: { show: true },
                        saveAsImage: { show: true }
                    }
                },
                series: [
                    {
                        name: 'Nightingale Chart',
                        type: 'pie',
                        radius: [50, 250],
                        center: ['50%', '50%'],
                        roseType: 'area',
                        itemStyle: {
                            borderRadius: 8
                        },
                        data: [
                            { value: 150, name: '男士外套' },
                            { value: 200, name: '帽子' },
                            { value: 250, name: '运动鞋' },
                            { value: 300, name: '牛仔裤' },
                            { value: 350, name: '防晒服' },
                            { value: 400, name: '城山' },
                            { value: 450, name: '短袖' },
                            { value: 500, name: '睡衣' }
                        ]
                    }
                ]
            });
        },
    },
    mounted() {
        // 基于准备好的dom，初始化echarts实例
        this.myChart = echarts.init(document.getElementById("main"));
        // 绘制图表
        this.init();
    },
});
</script>

<template>
    <div>
        <h1>饼状图表</h1>

        <div id="main"></div>
    </div>
</template>

<style lang="scss" scoped>
#main {
    height: 700px;
}
</style>
